package com.itheima.Mapper;

import com.itheima.Pojo.Emp;
import com.itheima.Pojo.EmpExpr;
import com.itheima.Pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {
//    @Select("select count(*) from emp")
////    Long count();
////    @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id limit #{start},#{pageSize}")
////    List<Emp> page(Integer start, Integer pageSize);
///
//        @Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id")
        // 基于XML开发动态SQL
        List<Emp> page(EmpQueryParam param);
    @Options(useGeneratedKeys = true,keyProperty = "id") // 获取主键的值并赋给id属性
    @Insert("insert into emp " +
            "values (null,#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updatTime})")
    void insert(Emp emp);


    /**
     * 批量删除员工数据
     * @param ids
     */
    // 基于注解XML开发--动态sql---foreach
    void deleteBatch(List<Integer> ids);


    /**
     * 根据员工id查询基本信息及经历列表信息
     * @param id
     * @return
     */
//    @Select("select * from emp e left join  emp_expr ee on e.id = ee.emp_id where e.id = #{id}")
    Emp getById(Integer id);

    void updateById(Emp emp);


    @MapKey("pos")
    List<Map<String, Object>> countEmpJobData();

    List<Map> countEmpGenderData();

    /**
     * 根据用户名密码启动
     * @param emp
     * @return
     */
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);
}
